package com.awn.weidian.demo.service;

import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;


@Service
public class DateHandle{
    
    //获取当前日期
    private SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


    //方法名为showTime 返回值为String
    public String showTime(){
        //时间转换
        String nowTime = df.format(new Date());
        return nowTime;
    }

    private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");


    public String createOrder(){
    	DateHandle a = new DateHandle();
        String oid = new String();
        oid += sdf.format(new Date());
        int max=9999;
        int min=1000;
        Random random = new Random();
        int s = random.nextInt(max)%(max-min+1) + min;
        int count = 10;
        int z[] = new int[count];
        
        for(int i =0 ; i<z.length; i++){
        	
        	if(s == z[i]){
        		a.createOrder();
        		count++;
        	}else{
        		oid += ""+s;
        		break;
        	}
        	
        }
        return oid;
    }

}

